package com.wangsh.usersCenter.users.pojo;

import java.util.Date;
import java.util.Map;
import java.util.TreeMap;

import com.wangsh.usersCenter.common.pojo.BasePojo;

/**
 * 角色菜单表
 * @author 王晨曦
 */
public class ARoleMenu extends BasePojo<ARoleMenu>
{
	
	/* 主键,自动递增 */
	private int id; 
	/* 角色Id */
	private int roleId; 
	/* 菜单Id */
	private int menuId; 
	/* 状态:0:禁用,1:启用 */
	private byte status; 
	/* 创建时间 */
	private Date createTime; 
	/* 更新时间 */
	private Date updateTime;
	/* 发布时间 */
	private Date pubTime;

	
	/*关联关系*/
	private ARole role;
	private AMenu menu;
	
	private String statusStr;
	/*
	 * 方便枚举项在网页上显示出来 键为值(数字),
	 * 值为字符串描述 
	 * 只提供get方法
	 */
	private Map<String,String> enumsMap = new TreeMap<String, String>();
	public Map<String, String> getEnumsMap()
	{
		// 根据状态值获取字符串描述
		ARoleMenuEnum[] roleMenuEnums = ARoleMenuEnum.values();
		for (int i = 0; i < roleMenuEnums.length; i++)
		{
			ARoleMenuEnum roleMenuEnum = roleMenuEnums[i];
			String key = roleMenuEnum.toString() ; 
			enumsMap.put(key + "-" + roleMenuEnum.getStatus() + "", roleMenuEnum.getName());
		}
		return enumsMap;
	}


	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public int getRoleId()
	{
		return roleId;
	}

	public void setRoleId(int roleId)
	{
		this.roleId = roleId;
	}

	public int getMenuId()
	{
		return menuId;
	}

	public void setMenuId(int menuId)
	{
		this.menuId = menuId;
	}

	public byte getStatus()
	{
		return status;
	}

	public void setStatus(byte status)
	{
		this.status = status;
	}

	public Date getCreateTime()
	{
		return createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	public Date getUpdateTime()
	{
		return updateTime;
	}

	public void setUpdateTime(Date updateTime)
	{
		this.updateTime = updateTime;
	}

	public Date getPubTime()
	{
		return pubTime;
	}

	public void setPubTime(Date pubTime)
	{
		this.pubTime = pubTime;
	}

	public ARole getRole()
	{
		return role;
	}

	public void setRole(ARole role)
	{
		this.role = role;
	}

	public AMenu getMenu()
	{
		return menu;
	}

	public void setMenu(AMenu menu)
	{
		this.menu = menu;
	}

	public String getStatusStr()
	{
		/* 获取所有的枚举项 */
		ARoleMenuEnum[] AUserARoleMenuEnums = ARoleMenuEnum.values();
		for (int i = 0; i < AUserARoleMenuEnums.length; i++)
		{
			ARoleMenuEnum AUserARoleMenuEnum = AUserARoleMenuEnums[i];
			/* 因为枚举项可能有好多,所以需要加一个判断 */
			if(AUserARoleMenuEnum.toString().startsWith("STATUS_"))
			{
				if(AUserARoleMenuEnum.getStatus() == this.getStatus())
				{
					this.statusStr = AUserARoleMenuEnum.getName();
				}
			}
		}
		return statusStr;
	}

	public void setStatusStr(String statusStr)
	{
		this.statusStr = statusStr;
	}

}
